//
//  UINavigationController+YJSuperExt.m
//  YJCategoriesGather
//
//  Created by YJHou on 2015/3/17.
//  Copyright © 2015年 侯跃军 houmanager@Hotmail.com. All rights reserved.
//

#import "UINavigationController+YJSuperExt.h"

@implementation UINavigationController (YJSuperExt)

+ (UINavigationController *)rootNavigationController {
    UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
    if ([rootViewController isKindOfClass:[UITabBarController class]]) {
        UITabBarController *tabBarVC = (UITabBarController *)rootViewController;
        UINavigationController *navigationController = (UINavigationController *)tabBarVC.selectedViewController;
        return navigationController;
    }else if ([rootViewController isKindOfClass:[UINavigationController class]]) {
        return (UINavigationController *)rootViewController;
    }else {
        return rootViewController.navigationController;
    }
}

@end
